/**
 * Copyright (c) 2016-2019 人人开源 All rights reserved.
 * <p>
 * https://www.renren.io
 * <p>
 * 版权所有，侵权必究！
 */

package com.sew.sewweb.common.config;


import com.sew.sewweb.common.exception.RRException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
import org.apache.commons.configuration.Configuration;
import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;


/**
 * 基础信息配置文件
 */
@Slf4j
@Component
public class BaseConfig implements ApplicationRunner {
    @Autowired
    private Environment environment;

    public static String system;//u8c系统编码
    public static String usercode;//u8c用户名
    public static String password;//u8c密码
    public static String unitAddUrl;//部门新增接口
    public static String menberAddUrl;//人员新增接口

    @Override
    public void run(ApplicationArguments args){
//        system = environment.getProperty("Cjjy.system");
//        usercode = environment.getProperty("Cjjy.usercode");
//        password = environment.getProperty("Cjjy.password");
//        unitAddUrl = environment.getProperty("Cjjy.unit.unitAddUrl");
//        menberAddUrl = environment.getProperty("Cjjy.menber.menberAddUrl");
    }

    /**
     * 获取配置信息
     */
    public static Configuration getConfig() {
        try {
            return new PropertiesConfiguration("sew.properties");
        } catch (ConfigurationException e) {
            throw new RRException("获取配置文件失败，", e);
        }
    }
}
